#include <iostream>
#include <unordered_map>
using namespace std;

int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int a, b, c, d;

  while (cin >> a >> b >> c >> d) {
    if ((a > 0 && b > 0 && c > 0 && d > 0) || (a < 0 && b < 0 && c < 0 && d < 0)) {
      cout << 0 << "\n";
      continue;
    }

    unordered_map<int, int> cnt;
    for (int x1 = 1; x1 <= 100; x1++) {
      for (int x2 = 1; x2 <= 100; x2++) {
        cnt[a * x1 * x1 + b * x2 * x2]++;
      }
    }

    c = -c;
    d = -d;
    int ans = 0;
    for (int x3 = 1; x3 <= 100; x3++) {
      for (int x4 = 1; x4 <= 100; x4++) {
        ans += cnt[c * x3 * x3 + d * x4 * x4];
      }
    }
    cout << ans * 16 << "\n";
  }
  return 0;
}